﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Web.Framework.Exceptions
{
    public static class ExceptionExtenssion
    {
        public static string GetExceptionMessage(this Exception ex)
        {
            StringBuilder builder = new StringBuilder();

            Exception current = ex;
            while (current != null)
            {
                builder.Append(current.Message);
                current = current.InnerException;
            }

            return builder.ToString();
        }

        public static string GetExceptionStackTrace(this Exception ex)
        {
            StringBuilder builder = new StringBuilder();

            Exception current = ex;
            while (current != null)
            {
                builder.Append(current.StackTrace);
                current = current.InnerException;
            }

            return builder.ToString();
        }
    }
}
